package com.liao.furn.lambda;

/**
 * @author lzp
 * @version 1.0
 * lzpnb!
 */
public class Test {
    public static void main(String[] args) {
        MyFunction<Desk,String> mf = new MyFunction<Desk, String>() {
            @Override
            public String apply(Desk desk) {
                return "hello,desk";
            }
        };
        String val = mf.apply(new Desk());
        System.out.println("val = " + val);

        MyFunction<Desk,String> mf2 = Desk::getName;
        String val2 = mf2.apply(new Desk());
        System.out.println("val2 = " + val2);
        MyFunction<Desk,String> mf3 = Desk::getBrand;
        String val3 = mf3.apply(new Desk());
        System.out.println("val3 = " + val3);
    }
}

@FunctionalInterface
interface MyFunction<T,R>{
    R apply(T t);

    default public void ok(){
        System.out.println("ok..");
    }
}

@FunctionalInterface
interface MyInterface{
    public void hi();
}

class Desk{
    private String name = "myDesk";
    private String brand = "jheh";

    public String getName() {
        return name;
    }

    public String getBrand() {
        return brand;
    }
}
